<html>
<head><meta charset="utf-8"><title>Termination using Display rather than Debug · edition 2021 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/index.html">edition 2021</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html">Termination using Display rather than Debug</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230559220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230559220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230559220">(Mar 16 2021 at 17:44)</a>:</h4>
<p>shortly after <code>?</code>-in-main was stabilized there was quite a bit of consternation (e.g. <a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-409188042">https://github.com/rust-lang/rust/issues/43301#issuecomment-409188042</a>) that the <code>impl Termination for Result&lt;_, impl Debug&gt;</code> should have been <code>impl Display</code> instead. does anyone think this is worth addressing in the new edition?</p>



<a name="230559610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230559610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230559610">(Mar 16 2021 at 17:47)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span> hm, seems like it'd be hard to make an automatic migration for that</p>



<a name="230559717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230559717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230559717">(Mar 16 2021 at 17:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230559220">said</a>:</p>
<blockquote>
<p>shortly after <code>?</code>-in-main was stabilized there was quite a bit of consternation (e.g. <a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-409188042">https://github.com/rust-lang/rust/issues/43301#issuecomment-409188042</a>) that the <code>impl Termination for Result&lt;, impl Debug&gt;</code> should have been <code>impl Display</code> instead. does anyone think this is worth addressing in the new edition?</p>
</blockquote>
<p>IIRC <span class="user-mention" data-user-id="222471">@BurntSushi</span> explicitly mentions this in a recent article <a href="https://github.com/benhoyt/countwords/blob/8553c8f600c40a4626e966bc7e7e804097e6e2f4/rust/simple/main.rs#L24-L33">https://github.com/benhoyt/countwords/blob/8553c8f600c40a4626e966bc7e7e804097e6e2f4/rust/simple/main.rs#L24-L33</a></p>



<a name="230561051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230561051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230561051">(Mar 16 2021 at 17:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230559610">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> hm, seems like it'd be hard to make an automatic migration for that</p>
</blockquote>
<p>I don't know how sophisticated the migration machinery is, but the migration is pretty rote: 1) see if <code>E</code> already implements <code>Display</code>, 2) if not, insert the following:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">std</span>::<span class="n">fmt</span>::<span class="n">Display</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">fmt</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">f</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">std</span>::<span class="n">fmt</span>::<span class="n">Formatter</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">std</span>::<span class="n">fmt</span>::<span class="nb">Result</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="fm">write!</span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="s">"{:?}"</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>so the question is, does rustfix have access to type information, or does it only work on tokens?</p>



<a name="230561467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230561467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230561467">(Mar 16 2021 at 17:56)</a>:</h4>
<p>rustfix uses suggestions from the compiler itself - I guess theoretically the compiler could see if there was already an impl? I don't think that's super common to do but it should be possible</p>



<a name="230561862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230561862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230561862">(Mar 16 2021 at 17:59)</a>:</h4>
<p>(though I guess coherence could be a problem, hm)</p>



<a name="230561873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230561873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230561873">(Mar 16 2021 at 17:59)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span> but that means if i return an <code>anyhow::Result</code>, i'll suddenly silently lose the error source chain. (it prints the chain with <code>{:?}</code>, but not with <code>{}</code>)</p>



<a name="230562427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230562427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230562427">(Mar 16 2021 at 18:01)</a>:</h4>
<p>(which was a design decision driven by the fact that we print the Debug and not the Display version in Termination)</p>



<a name="230562984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230562984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230562984">(Mar 16 2021 at 18:04)</a>:</h4>
<p>how does anyhow expect users to print the Display impl, then?</p>



<a name="230563292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230563292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230563292">(Mar 16 2021 at 18:06)</a>:</h4>
<p>Thinking just mechanism, without taking a position on whether it should: a 2021 binary could use <code>Termination2021</code> instead of <code>Termination2015</code>, which could have different implementations.</p>



<a name="230563398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230563398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230563398">(Mar 16 2021 at 18:07)</a>:</h4>
<p>yeah, my original comment was (unfortunately) made shortly after stabilization. i really wish i had caught it beforehand. <a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-388575730">https://github.com/rust-lang/rust/issues/43301#issuecomment-388575730</a></p>
<p>in "real" programs i tend to just use <code>anyhow</code> and it does the right thing because it hijacks the <code>Debug</code> impl, as <span class="user-mention" data-user-id="310399">@Mara</span> mentioned above. so in some sense, it's not a huge deal, but it would be really nice to have it fixed.</p>



<a name="230564073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230564073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230564073">(Mar 16 2021 at 18:11)</a>:</h4>
<p>since this has to do with anyhow, perhaps <span class="user-mention" data-user-id="119235">@David Tolnay</span> has some thoughts</p>



<a name="230564201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230564201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230564201">(Mar 16 2021 at 18:12)</a>:</h4>
<p>multiple traits could be an option to avoid silently breaking/changing behaviour, but i also don't want to end up with Thing2015 and Thing2021 for everything in std (:</p>



<a name="230564543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230564543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230564543">(Mar 16 2021 at 18:14)</a>:</h4>
<p>but maybe once the new try traits and Terminate are both stable, the current situation is much less of a problem. because you can just have some type <code>X</code> that you can use like <code>fn main() -&gt; X {}</code> which would allow <code>?</code> on Results and print them with Display or whatever you like. (and you could also modify/localise/stylize the hardcoded <code>"Error: "</code> prefix that we have now for <code>Result&lt;(), impl Debug&gt;</code>)</p>



<a name="230566696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230566696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230566696">(Mar 16 2021 at 18:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230564201">said</a>:</p>
<blockquote>
<p>i also don't want to end up with Thing2015 and Thing2021 for everything in std (:</p>
</blockquote>
<p>well, that means we just need <code>std2018</code>, <code>std2021</code>, and so on :P</p>



<a name="230566791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230566791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230566791">(Mar 16 2021 at 18:30)</a>:</h4>
<p>I definitely think at the <code>main</code> level that the arguments against mixing residuals get much weaker.  Like it'd be great to have a (maybe perma-unstable) type that rustdoc could use in its <code>main</code> that's <code>Termination</code> and allows you to <code>?</code> whatever you want.</p>



<a name="230566972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230566972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230566972">(Mar 16 2021 at 18:31)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="220273">@Jane Lusby</span> because error reporting</p>



<a name="230567003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567003">(Mar 16 2021 at 18:31)</a>:</h4>
<p>would a stable <code>try {}</code> also reduce the need for this? specifically, would a <code>catch</code> block replace the try_main pattern seen in burntsushi's code and the anyhow docs?</p>



<a name="230567073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567073">(Mar 16 2021 at 18:32)</a>:</h4>
<p>(I'm not even sure if <code>try {} catch {}</code> is being considered, I'm so confused as to the state of that feature)</p>



<a name="230567248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567248">(Mar 16 2021 at 18:33)</a>:</h4>
<p>not the <code>catch {}</code> part. the <code>try {}</code> block would return a Result or an Option, which you could use <code>.unwrap_or_else</code> on or whatever you want</p>



<a name="230567936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567936">(Mar 16 2021 at 18:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="310399">Mara</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230564543">said</a>:</p>
<blockquote>
<p>but maybe once the new try traits and Terminate are both stable, the current situation is much less of a problem. because you can just have some type <code>X</code> that you can use like <code>fn main() -&gt; X {}</code> which would allow <code>?</code> on Results and print them with Display or whatever you like. (and you could also modify/localise/stylize the hardcoded <code>"Error: "</code> prefix that we have now for <code>Result&lt;(), impl Debug&gt;</code>)</p>
</blockquote>
<p>i brought that up in my linked comment. the thing is, if i have to go and create my own type and impl a trait and all that just to get the right output, then i'm probably just going to write <code>try_main</code> instead. now if i already have my custom error type for other reasons, then yeah, it works nicely once <code>Termination</code> is stable.</p>



<a name="230567937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567937">(Mar 16 2021 at 18:37)</a>:</h4>
<p>We definitely cannot use Display</p>



<a name="230567957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567957">(Mar 16 2021 at 18:37)</a>:</h4>
<p>Sorry catching up still</p>



<a name="230567966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230567966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230567966">(Mar 16 2021 at 18:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230567073">said</a>:</p>
<blockquote>
<p>(I'm not even sure if <code>try {} catch {}</code> is being considered, I'm so confused as to the state of that feature)</p>
</blockquote>
<p>(The syntax space is reserved -- <a href="https://github.com/rust-lang/rust/blob/master/src/test/ui/try-block/try-block-catch.rs">https://github.com/rust-lang/rust/blob/master/src/test/ui/try-block/try-block-catch.rs</a> -- but there's no plan for semantics for <code>catch</code> that I know of.)</p>



<a name="230568364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568364">(Mar 16 2021 at 18:40)</a>:</h4>
<p><a href="https://github.com/yaahc/blog.rust-lang.org/blob/master/posts/inside-rust/2021-03-15-What-the-error-handling-project-group-is-working-towards.md">https://github.com/yaahc/blog.rust-lang.org/blob/master/posts/inside-rust/2021-03-15-What-the-error-handling-project-group-is-working-towards.md</a></p>



<a name="230568464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568464">(Mar 16 2021 at 18:40)</a>:</h4>
<p>This is a wip blog post that's gonna get published soon hopefully and the second section actually details my proposal for how we fix termination for Error types</p>



<a name="230568485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568485">(Mar 16 2021 at 18:40)</a>:</h4>
<p>Tho I think I might need to add a specific bullet to the summary for it</p>



<a name="230568667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568667">(Mar 16 2021 at 18:42)</a>:</h4>
<p>The gist is that we need some sort of error reporter in <code>std</code> that can access sources and print a full chain of errors</p>



<a name="230568716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568716">(Mar 16 2021 at 18:42)</a>:</h4>
<p>then we'd specialize <code>Termination</code> for <code>Result&lt;T, E: Error&gt;</code> so that it iterates over sources</p>



<a name="230568880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230568880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230568880">(Mar 16 2021 at 18:43)</a>:</h4>
<div class="codehilite"><pre><span></span><code>3. Add basic reporting logic for printing via the `Error` trait including source errors, possibly by integrating it directly with the `fmt` grammar
    * specialize `Termination` for `Result` when `E: Error` so that it prints the full chain of errors
</code></pre></div>



<a name="230569569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230569569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230569569">(Mar 16 2021 at 18:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="222471">BurntSushi</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230563398">said</a>:</p>
<blockquote>
<p>yeah, my original comment was (unfortunately) made shortly after stabilization. i really wish i had caught it beforehand. <a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-388575730">https://github.com/rust-lang/rust/issues/43301#issuecomment-388575730</a></p>
<p>in "real" programs i tend to just use <code>anyhow</code> and it does the right thing because it hijacks the <code>Debug</code> impl, as <span class="user-mention silent" data-user-id="310399">Mara</span> mentioned above. so in some sense, it's not a huge deal, but it would be really nice to have it fixed.</p>
</blockquote>
<p>reading this fully now, and I generally agree with the sentiment but not with the conclusino that we should use <code>Display</code>. This is counter to the design of the <code>Error</code> trait in my experience, which encourages us to use the <code>Display</code> impl for the error message of each individual error, so we'd lose context. I would however not be opposed to the argument that we should implement termination for <code>E: Display</code> and then specialize for <code>E: Error</code> to still print the chain of errors</p>



<a name="230569662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230569662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230569662">(Mar 16 2021 at 18:48)</a>:</h4>
<p>let me finish reading though to see if this is already addressed</p>



<a name="230570097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570097">(Mar 16 2021 at 18:51)</a>:</h4>
<p>regarding the last point, yea, I'm pretty worried that the ship has sailed on fixing the <code>Debug</code> vs <code>Display</code> impl issue, but I think we can fix it for errors at least which should be sufficient for the issues you raised</p>



<a name="230570131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570131">(Mar 16 2021 at 18:51)</a>:</h4>
<p>so long as you return a type that implements error it will use the display impls correctly _and_ iterate sources</p>



<a name="230570199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570199">(Mar 16 2021 at 18:52)</a>:</h4>
<p>and <code>Debug</code> doesn't sound like the worst fallback for debugging failures of non <code>Error</code> types</p>



<a name="230570226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570226">(Mar 16 2021 at 18:52)</a>:</h4>
<p>tho it's not particularly great for user experience :/</p>



<a name="230570589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570589">(Mar 16 2021 at 18:55)</a>:</h4>
<p>can we even do this kind of specialization?</p>



<a name="230570666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570666">(Mar 16 2021 at 18:55)</a>:</h4>
<p>my understanding is specializing <code>Error</code> over <code>Debug</code> should work because its strictly more specific</p>



<a name="230570770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570770">(Mar 16 2021 at 18:56)</a>:</h4>
<p>now that I think of it though</p>



<a name="230570784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570784">(Mar 16 2021 at 18:56)</a>:</h4>
<p>this change isn't really blocked by any of the other work on reporters and what not</p>



<a name="230570816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570816">(Mar 16 2021 at 18:56)</a>:</h4>
<p>we could implement the reporting logic by hand inside of the <code>Termination</code> impl</p>



<a name="230570823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570823">(Mar 16 2021 at 18:56)</a>:</h4>
<p>does it fall afoul of the same specialization problem that boats brings up in <a href="https://github.com/rust-lang/rust/issues/43301#issuecomment-428953929">https://github.com/rust-lang/rust/issues/43301#issuecomment-428953929</a> ?</p>



<a name="230570913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570913">(Mar 16 2021 at 18:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug/near/230570784">said</a>:</p>
<blockquote>
<p>this change isn't really blocked by any of the other work on reporters and what not</p>
</blockquote>
<p>yeah i'm implementing it now to play with it. but compiler says no.</p>



<a name="230570971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230570971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230570971">(Mar 16 2021 at 18:57)</a>:</h4>
<p>:(</p>



<a name="230571056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571056">(Mar 16 2021 at 18:58)</a>:</h4>
<p><span class="user-mention" data-user-id="310399">@Mara</span> you're specializing on <code>Error</code> right?</p>



<a name="230571073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571073">(Mar 16 2021 at 18:58)</a>:</h4>
<p>not <code>Debug + Display</code> as boats mentioned</p>



<a name="230571078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571078">(Mar 16 2021 at 18:58)</a>:</h4>
<p>yes</p>



<a name="230571082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571082">(Mar 16 2021 at 18:58)</a>:</h4>
<p>shit</p>



<a name="230571089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571089">(Mar 16 2021 at 18:58)</a>:</h4>
<p>whats the error?</p>



<a name="230571103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571103">(Mar 16 2021 at 18:58)</a>:</h4>
<p>(just curious)</p>



<a name="230571155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571155">(Mar 16 2021 at 18:58)</a>:</h4>
<p>this one: <a href="https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_typeck/impl_wf_check/min_specialization.rs.html#378">https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_typeck/impl_wf_check/min_specialization.rs.html#378</a></p>



<a name="230571197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571197">(Mar 16 2021 at 18:59)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: cannot specialize on trait `error::Error`
    --&gt; library/std/src/process.rs:1890:1
     |
1890 | / impl&lt;E: crate::error::Error&gt; Termination for Result&lt;!, E&gt; {
1891 | |     fn report(self) -&gt; i32 {
1892 | |         let Err(err) = self;
1893 | |         eprintln!(&quot;Error: {}&quot;, err);
...    |
1906 | |     }
1907 | | }
     | |_^
</code></pre></div>



<a name="230571466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571466">(Mar 16 2021 at 19:00)</a>:</h4>
<p>what's  a global predicate?</p>



<a name="230571477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571477">(Mar 16 2021 at 19:00)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="c1">// Global predicates are either always true or always false, so we</span>
<span class="w">        </span><span class="c1">// are fine to specialize on.</span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">predicate</span><span class="p">.</span><span class="n">is_global</span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">(),</span><span class="w"></span>
</code></pre></div>



<a name="230571505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571505">(Mar 16 2021 at 19:00)</a>:</h4>
<p>in this context</p>



<a name="230571532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571532">(Mar 16 2021 at 19:01)</a>:</h4>
<p>trying to understand this code</p>



<a name="230571620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571620">(Mar 16 2021 at 19:01)</a>:</h4>
<p>One that doesn't mention lifetime/type/const parameters (or inference variables, but there should be any of those here)</p>



<a name="230571907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571907">(Mar 16 2021 at 19:04)</a>:</h4>
<p>does that mean just concrete types?</p>



<a name="230571951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571951">(Mar 16 2021 at 19:04)</a>:</h4>
<p>with no parameters</p>



<a name="230571999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230571999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230571999">(Mar 16 2021 at 19:04)</a>:</h4>
<p>if so that's way more restricted than I realized X_X</p>



<a name="230572034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572034">(Mar 16 2021 at 19:04)</a>:</h4>
<p>if i stick <code>#[rustc_specialization_trait]</code> onto <code>trait Error</code> just for fun, a ton of things break. probably not supposed to do that then <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="230572058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572058">(Mar 16 2021 at 19:05)</a>:</h4>
<p>lol</p>



<a name="230572169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572169">(Mar 16 2021 at 19:05)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: cannot specialize on trait `Ord`
   --&gt; library/std/src/error.rs:475:1
    |
475 | / impl&lt;&#39;a, K: Debug + Ord, V: Debug&gt; Error
476 | |     for crate::collections::btree_map::OccupiedError&lt;&#39;a, K, V&gt;
</code></pre></div>
<p><span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="230572256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572256">(Mar 16 2021 at 19:06)</a>:</h4>
<p>??</p>



<a name="230572572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572572">(Mar 16 2021 at 19:08)</a>:</h4>
<p>it now accepts specialization for Error, but it'd indirectly specialize for Ord and Debug in the case of <code>OccupiedError&lt;'a, K: Debug + Ord, V: Debug&gt;</code>. since it'd have to pick the specialization of Termination based on K and V's bounds there in that case</p>



<a name="230572848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230572848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230572848">(Mar 16 2021 at 19:10)</a>:</h4>
<p>(whether <code>&lt;Result&lt;(), OccupiedError&lt;'a, E, V&gt; as Termination&gt;::report()</code> is the specialized or generic version depends on E and V's Ord/Debug impls now)</p>



<a name="230573420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230573420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230573420">(Mar 16 2021 at 19:14)</a>:</h4>
<p>slapping the attribute on <code>Ord</code> and <code>Debug</code> as well results in:</p>
<div class="codehilite"><pre><span></span><code>error: cannot specialize on `&#39;static` lifetime
   --&gt; library/core/src/any.rs:142:1
    |
142 | / impl fmt::Debug for dyn Any {
</code></pre></div>
<p>and at this point i feel like we probably shouldn't continue on this adventure of unsoundness :P</p>



<a name="230575801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230575801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230575801">(Mar 16 2021 at 19:29)</a>:</h4>
<p><span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="230575812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230575812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230575812">(Mar 16 2021 at 19:29)</a>:</h4>
<p>i appreciate the effort</p>



<a name="230579043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230579043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230579043">(Mar 16 2021 at 19:48)</a>:</h4>
<p>yeah i am not stuck on <code>Display</code> specifically. at the time i wrote that comment, i think that was the only other reasonable choice at the time.</p>



<a name="230599378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230599378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230599378">(Mar 16 2021 at 22:04)</a>:</h4>
<p>so is it safe to say that we're back to where we started here, only instead of <code>impl Termination for Result&lt;_, E: Display&gt;</code> we'd be considering <code>impl Termination for Result&lt;_, E: Error&gt;</code>? worst case scenario, the <code>Debug</code> fallback could be done using <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> compiler magic <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> instead of specialization (in which case, we may not even need an edition-related change), yeah?</p>



<a name="230604506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230604506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230604506">(Mar 16 2021 at 22:32)</a>:</h4>
<p>more or less</p>



<a name="230605323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230605323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230605323">(Mar 16 2021 at 22:40)</a>:</h4>
<p>it might even be worth considering abandoning the <code>E: Debug</code> impl entirely in the new edition, with the hope that most users are already using types that implement Error (and that those that aren't can just .unwrap() to essentially the same effect)</p>



<a name="230607692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Termination%20using%20Display%20rather%20than%20Debug/near/230607692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Termination.20using.20Display.20rather.20than.20Debug.html#230607692">(Mar 16 2021 at 23:02)</a>:</h4>
<p>I wonder if the <code>Debug</code> case could be moved to something like <code>fn main() -&gt; Yolo</code>, à la <a href="https://lib.rs/crates/yolo-block"><code>yolo!</code></a>, that's just "it's <code>unwrap</code>, but you write it with <code>?</code>".  And then the "shows something nice in a smart way" can use a different type.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>